package net.hn.hnms.biz.safety.trinity.dao;

import net.hn.hnms.biz.safety.trinity.entity.NormCheckScore;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 智呈物联 nzw
 * @date 2022/8/5
 */
@Repository
public interface NormCheckScoreDao extends JpaRepository<NormCheckScore,String> {

    NormCheckScore findByCheckName(String name);

    @Query(value = "SELECT\n" +
            "\t* \n" +
            "FROM\n" +
            "\tnorm_check_score \n" +
            "WHERE\n" +
            "\tCASE when ?1 != '' then trim(mine_code) = ?1 else 1=1 end " +
            "ORDER BY\n" +
            "\tcheck_year,\n" +
            "\tcheck_month",nativeQuery = true)
    List<NormCheckScore> findAllSort(String mineCode);
}
